/*
* @Author: admin
* @Date:   2018-07-05 10:36:45
* @Last Modified by:   admin
* @Last Modified time: 2018-07-05 11:04:52
*/
var events = require('events');
var eventEmitter = new events.EventEmitter();

var listener1 = function(){
	console.log('监听器 listener1 执行');
}

var listener2 = function(){
	console.log('监听器 listener2 执行');
}

eventEmitter.addListener('connection',listener1);
eventEmitter.addListener('connection',listener2);

var eventListeners  = require('events').EventEmitter.listenerCount(eventEmitter,'connection');
console.log(eventListeners +" 个监听器监听连接事件");

eventEmitter.emit('connection');

eventEmitter.removeListener('connection',listener1);
console.log('Listener1 不再受监听');

eventEmitter.emit('connection');

eventListeners  = require('events').EventEmitter.listenerCount(eventEmitter,'connection');
console.log(eventListeners  + " 个监听器监听连接事件。");

console.log("程序执行完毕");


